package com.cbnu.SmartCampusLife;

import java.io.FileOutputStream;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;

@SuppressLint("WorldReadableFiles")
public class TakeScreenShot extends Thread {
	private String fileName;
	private View view;
	private Context context;

	public TakeScreenShot(String fileName, View view, Context context) {
		this.fileName = fileName;
		this.view = view;
		this.context = context;
	}

	@Override
	public void run() {
		view.buildDrawingCache();
		Bitmap bmp = view.getDrawingCache();
		try {
			FileOutputStream fos;
			fos = context.openFileOutput(fileName, Context.MODE_WORLD_READABLE);
			bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
			fos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}